package com.dona.imsidetector.db.entity;

import com.dona.imsidetector.utils.IMSIUtil;

import org.xutils.db.annotation.Column;
import org.xutils.db.annotation.Table;

import java.util.Date;

@Table(name = "imsi")
public class Imsi {
    @Column(name = "uuid", isId = true)
    private String uuid;

    @Column(name = "imsi")
    private String imsi;

    @Column(name = "power")
    private Float power;

    @Column(name = "freq")
    private Integer freq;

    @Column(name = "time")
    private long time;

    @Column(name = "isp")
    private String isp; // 运营商

    @Column(name = "province")
    private String province; // 运营商所在的省

    @Column(name = "city")
    private String city; // 运营商所在的省的市

    private Double lng;

    private Double lat;

    private Integer deviceId;

    private Integer count = 0;

    private Integer isWhite = -1; // 0:黑名单 1：白名单 -1：初始化

    private Integer isRead = 0; // 0未读 1已读

    public Imsi(){}


    public Imsi(String imsi, Float power, Integer freq, Integer deviceId) {
        this.imsi = imsi;
        this.power = power;
        this.freq = freq;
        this.time = System.currentTimeMillis();
        this.deviceId = deviceId;
        this.isp = IMSIUtil.getISPbyImsi(imsi);
    }

    public Integer getDeviceId() {
        return deviceId;
    }

    public void setDeviceId(Integer deviceId) {
        this.deviceId = deviceId;
    }



    public Float getPower() {
        return power;
    }

    public void setPower(Float power) {
        this.power = power;
    }

    public String getUuid() {
        return uuid;
    }

    public void setUuid(String uuid) {
        this.uuid = uuid;
    }

    public String getImsi() {
        return imsi;
    }

    public void setImsi(String imsi) {
        this.imsi = imsi;
    }

    public Integer getFreq() {
        return freq;
    }

    public void setFreq(Integer freq) {
        this.freq = freq;
    }

    public long getTime() {
        return time;
    }

    public void setTime(long time) {
        this.time = time;
    }

    public String getIsp() {
        return isp;
    }

    public void setIsp(String isp) {
        this.isp = isp;
    }

    public String getProvince() {
        return province;
    }

    public void setProvince(String province) {
        this.province = province;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public Integer getCount() {
        return count;
    }

    public void setCount(Integer count) {
        this.count = count;
    }

    public Integer getIsWhite() {
        return isWhite;
    }

    public void setIsWhite(Integer isWhite) {
        this.isWhite = isWhite;
    }

    public Integer getIsRead() {
        return isRead;
    }

    public void setIsRead(Integer isRead) {
        this.isRead = isRead;
    }

    public Double getLng() {
        return lng;
    }

    public void setLng(Double lng) {
        this.lng = lng;
    }

    public Double getLat() {
        return lat;
    }

    public void setLat(Double lat) {
        this.lat = lat;
    }

    public String getImsiInfo(){
        StringBuilder sb = new StringBuilder(this.imsi + " ");
        if(null != isp){
            sb.append(isp);
        }
        if(null != province){
            sb.append(province);
        }
        return sb.toString();
    }

    public String getLocation(){
        StringBuilder sb = new StringBuilder("");
        if(null != province){
            sb.append(province);
        }
        if(null != isp){
            sb.append(isp);
        }

        return sb.toString();
    }

    @Override
    public String toString() {
        return "ImsiBean{" +
                "imsi='" + imsi + '\'' +
                ", power=" + power +
                ", time=" + time +
                '}';
    }
}
